<?php
function include_stylesheet($name) {
	$include = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . STYLESHEET_PATH . "$name.css\" />\n";
	echo $include;
}

function include_javascript($name) {
    $include = "<script type=\"text/javascript\" src=\"" . JAVASCRIPT_PATH . "$name.js\"></script>\n";
    echo $include;
}

function image_tag($image, $options = array()) {
    $tag = '<img src="%s"%s />';
    
    $in_site = ($options["in_site"] === false) ? false : true;
    $src = ($in_site) ? IMAGES_PATH . $image : $image;
    $attributes = "";
    
    foreach($options as $key => $value) {
        if($key == "in_site") continue;
        
        $attributes .= " $key=\"$value\"";
    }
    
    $tag = sprintf($tag, $src, $attributes);
    
    return $tag;
}

function link_tag($text, $href, $options = array()) {
    $tag = "<a%s>%s</a>";
    
    $in_site = ($options["in_site"] === false) ? false : true;
    
    $class = get_class($href);
    if($class === false) {
        $href = ($in_site) ? ROOT . $href : $href;
    }
    else {
        $href = ROOT . underscorify($class) . '/' . $href->id . '/' . ((empty($options["object_action"])) ? 'show' : $options["object_action"]);
    }
    $href .= ($options["is_script"] === true) ? '.htm' : '';
    $href .= (empty($options["get"])) ? '' : '?' . $options["get"];
    $attributes = " href=\"$href\"";
    
    foreach($options as $key => $value) {
        if($key == "in_site" or $key == "object_action" or $key == "is_script" or $key == "get") {
            continue;
        }
        $attributes .= " $key=\"$value\"";
    }
    
    $tag = sprintf($tag, $attributes, $text);
    
    return $tag;
}
?>